import {useCallback, useState} from 'react';

export default function useAuthModel() {
    // const userInfo = JSON.parse(<string>localStorage.getItem('userinfo')) ;
    const userInfo = {};
    const userObj = {
        avatar: '',
        username: '',
    };
    const [user, setUser] = useState(userInfo ? userInfo : userObj);

    const setuserInfo = useCallback((e) => {
        setUser({...e});
        window.localStorage.setItem('userinfo', JSON.stringify(e));
    }, []);

    return {
        user,
        setuserInfo,
    };
}
